<template>
    <div class="car">
        <div class="icon" @click="isShows">
            <img src="../img/cart.png" alt="" v-if="isShow">
            <img src="../img/gwc.png" alt=""  v-else>
        </div>
        <i v-show="sitList">{{ sitList }}</i>
        <p>
            <span>￥{{ sitPrice }}</span>
            <b>另需配送费￥4元</b>
        </p>
        <span class="right">
            ￥20元起送
        </span>
    </div>
</template>

<script>
import { mapState, mapMutations, mapGetters, mapActions } from 'vuex'
export default {
    methods: {
        ...mapMutations(['isShows'])
    },
    computed: {
        ...mapState(['carList','isShow']),
        sitPrice() {
            let price = 0
            this.carList.forEach(item => {
                price += item.id * item.price
            })
            return price
        },
        sitList() {
            let amount = 0
            this.carList.forEach(item => {
                amount += item.id
            })
            return amount
        }

    }
}
</script>

<style lang="less" scoped>
.car {
    width: 100%;
    height: 15.4667vw;
    padding-left: 4.8vw;
    box-sizing: border-box;
    background-color: rgb(0 0 0 /.9);
    display: flex;
    align-items: center;
    position: fixed;
    bottom: 0;
    left: 0;
    z-index: 999;
    color: rgb(255 255 255 /.4);

    .icon {
        width: 13.3333vw;
        height: 13.3333vw;
        border-radius: 50%;
        margin-right: 4.8vw;
        display: flex;
        justify-content: center;
        align-items: center;
        background-color: #000;
        border: 1.6vw solid rgb(0 0 0 / .9);
        transform: translateY(-20%);
        img {
            width: 150%;
            background-color: #000;
            border-radius: 50%;
        }

       
    }
    i {
            width: 6.4vw;
            height: 4vw;
            background-color: red;
            position: absolute;
            left: 14.6667vw;
            top: -25%;
            border-radius: 2vw;
            font-size: 1.3333vw;
            display: flex;
            justify-content: center;
            align-items: center;
            font-style: normal;
            color: #fff;
        }
    p {
        height: 100%;
        display: flex;
        align-items: center;
        flex: 1;

        span {
            font-size: 5.3333vw;
            font-weight: 800;
            position: relative;
            width: 21.3333vw;
            height: 100%;
            line-height: 16vw;

            &::after {
                content: '';
                display: block;
                height: 10.6667vw;
                width: .1333vw;
                background-color: rgb(255 255 255 /.2);
                position: absolute;
                right: 4vw;
                top: 50%;
                transform: translateY(-50%);
            }
        }

        b {
            line-height: 1;
            font-size: 3.2vw;
        }
    }

    .right {
        width: 24vw;
        height: 100%;
        display: flex;
        justify-content: center;
        align-items: center;
        font-size: 3.2vw;
        background-color: rgb(128 128 128 /8);
    }
}
</style>